All Questions
50 questions
3votes
1answer
326views
Applying the Strategy pattern for payment methods
The strategy pattern is applied in the code below in the payment separation solution. Please evaluate if it is well done according to standards. I would be very grateful for suggestions. ...
6votes
2answers
503views
Usage of Factory pattern for maintaing bookshelf having books, magazine and notes
I have tried to achieve the following task using Factory Pattern with PHP version 7.0. Define the classes and their methods (including parameters and return types) for a system that consist of a ...
2votes
1answer
79views
Transform Data from JSON and CSV to another JSON format
I have 2 files wholesaler_a.csv ...
1vote
1answer
66views
Chain of responsibility and handlers dependent on each other
I'm importing data from file to many tables in database. It may look like this: First Name, Last Name, Meeting John, Doe, 2020-04-24 08:00:00 Some fields like "...
2votes
0answers
99views
router system like laravel, how to manage routes creation and router handler?
i'm trying to create a url router system, for educational purposes, that has a similar usage like Laravel has, but i'm curious about how i can register the routes like laravel does (with single calls ...
2votes
0answers
92views
implementation of a mvc url router with low coupling and solid principles
i'm building an url router and i want to improve it to respect SOLID principles, i want suggestions of how can i make it less coupled. here's my current code: Router.php ...
3votes
2answers
82views
Organise method flow
I have something like a shop. It is limited to a checkout page, which will send an email. Nothing big, but a nice thing to learn more OOP. Almost every time I develop new classes I am wondering how ...
4votes
1answer
287views
strategy pattern, good practices on how to switch between classes
i'm using an external API that posts products and orders into a marketplace, and it provides a class that in each request i have to specify an endpoint, ...
6votes
1answer
162views
Adapter pattern to support multiple file storage systems
I am just getting into the following design patterns. I have created a class that allows for performing a couple of operations on different remote storage systems: drive, dropbox, .etc (I call these <...
1vote
1answer
43views
Adding Length dimension to a Crate Object
Consider Crate::addLength() in the following code: ...
6votes
2answers
501views
SOLID principles breaking in interview task (file parser)
Originally asked on Stack Overflow I recently had an interview where interviewers asked me to Rewrite following code with SOLID principles. Add a new file handler (...
0votes
1answer
122views
User class: getting user data, logging in, secure CSRF session handling, logging out
In reference to my previous code: User class: getting user data, logging in, secure CSRF session handling I re-wrote my SystemUser class, without the DI container (for now), I'm still trying to ...
2votes
1answer
153views
User class: getting user data, logging in, secure CSRF session handling
I wrote this class a few months ago and noticed from a few examples that it's better to break down these classes and separate them. I am not so sure what is the proper way to break it into parts. It ...
2votes
0answers
2kviews
Simple bank OOP structure in PHP
I don't have much experience using either OOP or PHP since this is probably my first thing ever written in this language. I've had some exposure to OOP but I'm not used to writing programs that way. I ...
0votes
1answer
512views
PHP OOP registration with User class and singleton Database class [closed]
I created registration system with PHP. I have User class that will handle all the input and insert the user input into database, and i created Database class with Singleton pattern that will connect ...